1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package com.google.common.collect;
18
19 import com.google.common.annotations.GwtCompatible;
20 import com.google.common.base.Objects;
21
22 import java.util.Map.Entry;
23
24 import javax.annotation.Nullable;
25
26
27
28
29
30
31
32 @GwtCompatible
33 abstract class AbstractMapEntry<K, V> implements Entry<K, V> {
34
35 @Override
36 public abstract K getKey();
37
38 @Override
39 public abstract V getValue();
40
41 @Override
42 public V setValue(V value) {
43 throw new UnsupportedOperationException();
44 }
45
46 @Override public boolean equals(@Nullable Object object) {
47 if (object instanceof Entry) {
48 Entry<?, ?> that = (Entry<?, ?>) object;
49 return Objects.equal(this.getKey(), that.getKey())
50 && Objects.equal(this.getValue(), that.getValue());
51 }
52 return false;
53 }
54
55 @Override public int hashCode() {
56 K k = getKey();
57 V v = getValue();
58 return ((k == null) ? 0 : k.hashCode()) ^ ((v == null) ? 0 : v.hashCode());
59 }
60
61
62
63
64 @Override public String toString() {
65 return getKey() + "=" + getValue();
66 }
67 }